<% layout('/layout/default.html', {title: '流程模型管理', libs: ['dataGrid']}){ %>
<div class="main-content">
	<div class="card-header">
		<i class="fa fa-sitemap"></i> 流程模型管理
		<div class="header-tools float-right">
			<a href="#" class="btn btn-default btn-sm" id="btnSearch" title="查询"><i class="fa fa-filter"></i> 查询</a>
			<% if(hasPermi('act:model:edit')){ %>
			<a href="${ctxStatic}/modler/index.html#/processes" class="btn btn-default btn-sm btnTool"  title="新增流程模型" data-type="layer"><i class="fa fa-plus"></i> 新增</a>
			<% } %>
		</div>
	</div>
	<div class="container-fluid">
		<form id="searchForm" action="${ctx}/act/model/listData" class="form-inline d-none">
			<div class="form-group">
				<label class="control-label">模型标识KEY：</label>
				<div class="control-inline">
					<input name="key" maxlength="100" class="form-control form-control-sm"/>
				</div>
			</div>
			<div class="form-group">
				<label class="control-label">模型名称：</label>
				<div class="control-inline">
					<input name="name" maxlength="100" class="form-control form-control-sm"/>
				</div>
			</div>
			<div class="form-group">
				<button type="submit" class="btn btn-success btn-sm ">查询</button>
				<button id="reset" type="reset" class="btn btn-default btn-sm">重置</button>
			</div>
		</form>
		<table id="dataGrid"></table>
		<div id="dataGridPage"></div>
	</div>
</div>
<% } %>
<script>
	$('#dataGrid').dataGrid({
		searchForm: $("#searchForm"),
		columnModel: [
			{header:'模型名称', name:'name', index:'a.name', width:100, align:"center" },
			{header:'模型标识KEY', name:'key', index:'a.model_key', width:100, align:"center" },
			{header:'版本号', name:'version', index:'a.version', width:80, align:"center" , formatter:function(val, obj, row, act){
					return "V:" + val;
				}},
			{header:'创建时间', name:'created', index:'a.created', width:100, align:"center", formatter:"date" },
			{header:'最后更新时间', name:'lastUpdated', index:'a.last_updated', width:100, align:"center", formatter:"date" },
			{header:'操作', name:'actions', width:100, sortable:false, title:false, align:"center",formatter: function(val, obj, row, act){
					var actions = [];
				<% if(hasPermi('act:model:edit')){ %>

						actions.push('<a href="${ctxStatic}/modler/index.html#/editor/'+row.id+'" class="btnList" title="流程模型编辑" data-type="layer"><i class="fas fa-pencil-alt"></i></a>&nbsp;');
						actions.push('<a href="${ctxStatic}/formdesign/index.html?modelId='+row.id+'&modelKey='+row.key+'&modelVersion='+row.version+'" class="btnList" title="表单配置" data-type="layer"><i class="fa fa-fire"></i></a>&nbsp;');
						actions.push('<a href="${ctx}/act/model/deploy?id='+row.id+'" class="btnList" title="部署" data-formtitle="流程分类" data-type="form" data-formurl="${ctx}/act/model/choose/category"><i class="fa fa-bolt"></i></a>&nbsp;');
						actions.push('<a href="${flow}/app/rest/models/'+ row.id +'/bpmn20' + '" title="下载" ><i class="fa fa-download"></i></a>&nbsp;');
						actions.push('<a href="${ctx}/act/model/delete?id='+row.id+'" class="btnList" title="删除" data-confirm="确认要删除该模型吗？"><i class="far fa-trash-alt"></i></a>&nbsp;');

					<% } %>

					return actions.join('');
				}}
		],
		// 加载成功后执行事件
		ajaxSuccess: function(data){

		}
	});

</script>